/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cgi.ndk.wf.controller;

import com.cgi.ndk.wf.service.TaskServiceActiviti;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author kovalcikm
 */
@RestController
@RequestMapping("/v2/task")
public class TaskControllerActivity {

    @Autowired
    TaskServiceActiviti taskServiceActiviti;

    @RequestMapping(value = "/getAll", produces = "application/json")
    public Object getAllTasks() {
        return taskServiceActiviti.getAllTasks();
    }

    @RequestMapping(value = "/getDetail/{instanceId}", method = RequestMethod.GET, produces = "application/json")
    public Object getTaskDetail(@PathVariable("instanceId") String instanceId) {
        return taskServiceActiviti.getTaskDetail(instanceId);
    }

    @RequestMapping(value = "/change", method = RequestMethod.PUT, produces = "application/json", consumes = "application/json")
    public Object changeTask(@PathVariable("instanceId") String instanceId, @RequestBody Object changeTask) {
        return taskServiceActiviti.changeTask(instanceId, changeTask);
    }

    @RequestMapping(value = "/complete/{instanceId}", method = RequestMethod.GET, produces = "application/json")
    public Object completeTask(@PathVariable("instanceId") String instanceId) {
        return taskServiceActiviti.complete(instanceId);
    }

    @RequestMapping(value = "/claim/{instanceId}/{user}", method = RequestMethod.GET, produces = "application/json")
    public Object claimTask(@PathVariable("instanceId") String instanceId, @PathVariable("user") String user) {
        return taskServiceActiviti.claim(instanceId, user);
    }

}
